import Vue from 'vue';
import Vuex from 'vuex';
import './assets/css/app.css';
import './assets/css/light.css';
import './assets/css/dark.css';
import 'lib-flexible/flexible'
import echarts from 'echarts'
import 'element-ui/lib/theme-chalk/index.css';
import ElementUI from 'element-ui';
import VueRouter from 'vue-router';
import JsonViewer from 'vue-json-viewer'
import Root from './root/root.vue';



Vue.use(Vuex);
const store = new Vuex.Store({
    state: {
        theme: "light", //主题
        init: false,
        config: {
            webTitle: 'APIBE', //系统名称
            isCollapse: false, //默认折叠垂直菜单栏
            isHeaderHide: true, //头部是否可隐藏
            isVertical: true, //默认使用垂直菜单
            isXs: true, //判断是否隐藏横向菜单和面包屑，请不要改动
            // informNum: 12 //新通知数
        },
        currentUser: {},
    },
    mutations: {
        setInit: function (state, data) {
            state.inited = data;
        },
        setConfig: function (state, data) {
            state.config = data;
        },
        setCurrentUser: function (state, data) {
            state.currentUser = data;
        }
    }
});


Vue.prototype.$echarts = echarts

Vue.use(ElementUI);

//动态获取路由
let children = [];
let menuTree = getMenuTree();

// 不同的角色拥有不同的权限
function getMenuTree() {
    return require("./assets/json/menu.json")
}

function acquireRoute(e) {
    for (let i = 0; e.length > i; i++) {
        children.push({
            path: e[i].path, name: e[i].name, component: resolve => require([`${e[i].component}`], resolve)
        });
        if (e[i].childTreeDto && e[i].childTreeDto.length >= 1) {
            acquireRoute(e[i].childTreeDto);
        }
    }
}

acquireRoute(menuTree);
let routes = [
    {path: '/login', name: '登录', component: resolve => require(['./root/root-login.vue'], resolve)},
    {path: '/main', name: '主页', component: resolve => require(['./root/root-main.vue'], resolve), children: children},
];
Vue.use(VueRouter);
const router = new VueRouter({ // 将页面组件注册到路由
    routes: routes
});

Vue.use(JsonViewer)

new Vue({
    render: h => h(Root),
    router: router,
    store: store
}).$mount('#root');


import JsonExcel from 'vue-json-excel'

Vue.component('downloadExcel', JsonExcel)


